package com.zhm.springcloud.service.impl;

import com.zhm.springcloud.dao.AccountDao;
import com.zhm.springcloud.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * Date： 2021/3/21 12:53
 *
 * @author ZHM
 */
@Service
@Slf4j
public class AccountServiceImpl implements AccountService {

    @Resource
    private AccountDao accountDao;

    /**
     * 扣减账户余额
     */
    @Override
    public void decrease(Long userId, BigDecimal money) {
        log.info("------>account-service中扣减账户余额开始");
        //模拟超时异常，全局事务回滚
        accountDao.decrease(userId, money);
        log.info("------->account-service中扣减账户余额结束");
    }


}
